//-----------------------------------------------------------------------------
// Name: Gun.cpp
// Auth: Paul Godfrey
// Desc: Handles the creation and destruction of a Gun
//-----------------------------------------------------------------------------

#include "Gun.h"
#include "SharedConstants.h"
#include <iostream>
#include "rifle.h"
#include "shotgun.h"
#include "vaccine.h"
#include "DisplayManager.h"

static int Guncount = 0;
cGun gGun;


//-----------------------------------------------------------------------------
// Functions:
//-----------------------------------------------------------------------------
cGun* GetGun()
{
	return &gGun;
}
//Default constructor
cGun::cGun() :
	mClipSize(3),
	mActive(false)
{

}

//Constructor that takes in position, yaw and pitch
cGun::cGun(int c, bool a, enum eGunType g) :
	mClipSize(c),
	mActive(a),
	mType(g)
{
}

cGun::~cGun()
{
}

//Set gun to the active one
void cGun::SetActive(bool b)
{
	mActive=b;
}

//Gets active gun type
bool cGun::GetActive()
{
	return mActive;
}

//Get clip size
int cGun::GetClipSize()
{
	return mClipSize;
}

//Moves gun
void cGun::Move(float x, float y, float z)
{
	mXPosition = x;
	mYPosition = y;
	mZPosition = z;
	//printf("%f, %f, %f\n", mXPosition, mYPosition, mZPosition);
}

//Sets gun pitch
void cGun::SetPitch(float p)
{
	mPitch = p;
}

//Sets Gun yaw
void cGun::SetYaw(float y)
{
	mYaw = y;
}


//Draw a weapon based on its type
void cGun::Draw(float x, float y, float z, float ya, float p)
{
	//TODO: Other part of memory leaks are in gun draws

	switch(mType)
	{
	case Vaccine:
		{
			cVaccine* pVaccine = GetVaccine();
			pVaccine->Draw(x,y,z,ya,p);
		}
		break;
	case 2:
		break;
	case 3:
		break;
	case Rifle:
		{
			cRifle* pRifle = GetRifle();
			pRifle->Draw(x,y,z,ya,p);
		}
		break;
	case Shotgun:
		{
			cShotgun* pShotgun = GetShotgun();
			pShotgun->Draw(x,y,z,ya,p);
		}
		break;
	}
}

//Gets gun type
eGunType cGun::GetType()
{
	return mType;
}

//Gets gun damage based on type
int cGun::GetDamage()
{

	switch(mType)
	{
	case Vaccine:
		return 0;
		break;
	case 2:
		return 0;
		break;
	case 3:
		return 0;
		break;
	case Rifle:
		{
			cRifle* pRifle = GetRifle();
			return pRifle->GetDamage();
		}
		break;
	case Shotgun:
		{
			cShotgun* pShotgun = GetShotgun();
			return pShotgun->GetDamage();
		}
		break;
	}
	return 0;
}